package com.study.d012Components;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

/**
*@description 滚动条面板
*@author xtayhame
*date 2020年3月3日
*version
*since v1.0
*/
public class ScollPanelMain extends Application{
	public static void main(String[] args) {
		launch(args);

	}

	@Override
	public void start(Stage stage) throws Exception {
		AnchorPane anchorPane = new AnchorPane();

		HBox hb = new HBox();
		for(int i=0;i<200;i++){
			Button b = new Button("H-Button-"+i);
			hb.getChildren().add(b);
		}

		VBox vb = new VBox();
		for(int i=0;i<20;i++){
			Button b = new Button("V-Button-"+(i+20));
			vb.getChildren().add(b);
		}

		VBox  hb2 = new VBox();
		hb2.getChildren().addAll(hb,vb);

		ScrollPane sp = new ScrollPane();
		sp.setContent(hb2);
		//需要设置宽和高，才能显示出来


		anchorPane.getChildren().add(sp);

		stage.setScene(new Scene(anchorPane, 300, 400));
		stage.show();

		sp.setPrefWidth(stage.getWidth()-40);
		sp.setPrefHeight(stage.getHeight()-50);

	}


}
